const searchRight = document.querySelector(".search-right")
const searchActive = document.querySelector(".search-active")
searchRight.onmouseover = function(){
    searchActive.style.display ="block";
}
searchRight.onmouseout = function(){
    searchActive.style.display ="none";
}

const toprights = document.querySelector(".toprights")
const toprlist = document.querySelector(".top-right-mylist")
toprights.onmouseover = function(){
    toprlist.style.display ="block";
}
toprights.onmouseout = function(){
    toprlist.style.display ="none";
}

const toprighttf = document.querySelector(".toprighttf")
const toprimg = document.querySelector(".top-right-img")
toprighttf.onmouseover = function(){
    toprimg.style.display ="block";
}
toprighttf.onmouseout = function(){
    toprimg.style.display ="none";
}

const fixedleft= document.querySelector("#fixedleft")
document.addEventListener("scroll",function(){
    if(window.pageYOffset >=1500){
        fixedleft.style.display="block"
    }else{
        fixedleft.style.display="none"
    }
    // console.log(window.pageYOffset)
})

const fspan = document.querySelectorAll(".fixedleft-span")
for(let i=0;i<fspan.length;i++){
    fspan[i].onmouseover =function(){
        fspan[i].style.color="red"
    }
    fspan[i].onmouseout =function(){
        fspan[i].style.color="#9d9d9d"
    }

document.addEventListener("scroll",function(){
    if(window.pageYOffset >1500+(i*605) && window.pageYOffset<3000+(i+1)*700){
        for(let j=0;j<fspan.length;j++){
            fspan[j].style.color="#9d9d9d"
        }
        fspan[i].style.color="red"
        
    }if(window.pageYOffset<8000 && window.pageYOffset>6400){
        fspan[i].style.color="#9d9d9d"
    }
        
})
}


const activet= document.querySelector(".activet")
document.addEventListener("scroll",function(){
    if(window.pageYOffset >=600){
        activet.style.display="block"
    }else{
        activet.style.display="none"
    }
    // console.log(window.pageYOffset)
})

const fixedCont=document.querySelector(".fixed-cont")
document.addEventListener("scroll",function(){
    if(window.pageYOffset >=600){
        fixedCont.style.display="block"
    }else{
        fixedCont.style.display="none"
    }
    // console.log(window.pageYOffset)
})

var ul=document.querySelector(".hero-info ul")
var ol=document.querySelector(".hero-dots")
var  heroInfo =document.querySelector(".hero-info")
var menur = document.querySelector(".hero-menu-right")
var menul = document.querySelector(".hero-menu-left")
var imgWidth = heroInfo.offsetWidth

console.log(ul.children.length)
for(var i=0;i<ul.children.length;i++){
 var li=document.createElement("li")
 li.setAttribute("index",i)
 ol.appendChild(li)
 li.addEventListener("click",function(){
     for(let i=0;i<ol.children.length;i++){
        ol.children[i].className=""
     }
     this.className="current"
     var index =this.getAttribute("index")
     num=index
     circle=index
     console.log(index)
     console.log(imgWidth)
     animate(ul,{
         left:-index * imgWidth
    })
 })
}
ol.children[0].className="current"
var first = ul.children[0].cloneNode(true);

ul.appendChild(first)
var num=0
var circle =0
menur.addEventListener("click",function(){
    if(num == ul.children.length-1){
        ul.style.left =0
        num = 0
    }
    
    num=(Math.round(-(ul.offsetLeft-1190)/1190))

    // num++;
    animate(ul,{
        left:-num* imgWidth
    })
    circle++;
    if(circle == ol.children.length){
        circle=0
    }
    for(var i=0;i<ol.children.length;i++){
        
        ol.children[i].className="";
    }
    ol.children[circle].className="current"
})

menul.addEventListener("click",function(){
    if(num == 0){
        num= ul.children.length-1
        ul.style.left =-num *imgWidth+"px"
    }
    
    // num=(Math.round((ul.offsetLeft-1190)/1190))
    num--;
    // num++;
    animate(ul,{
        left:-num* imgWidth
    })
    circle--;
    if(circle == -1){
        circle=ol.children.length-1
    }
    for(var i=0;i<ol.children.length;i++){
        
        ol.children[i].className="";
    }

    ol.children[circle].className="current"
})
var t= setInterval(() => {
    menur.click()
}, 2000);

var host=document.querySelector(".brand-active")
var pbox=document.querySelector(".brand-showh")
var dujia=document.querySelector(".dujia")
var jbox=document.querySelector("#brandclick")
host.onclick=function(){
    jbox.style.display="none"
    pbox.style.display="flex"
}
dujia.onclick=function(){
    jbox.style.display="flex"
    pbox.style.display="none"
}




const token = sessionStorage.getItem("isLogin") ? JSON.parse(sessionStorage.getItem("isLogin")) : {};


if(token.code === "OK"){
    $("#denglu").hide();
    $("#zhuce").hide();
    $("#sjyzmdl").hide();
    $("#Hoverone").show();
    $("#tuichu").show();
    $("#Hoverone").children("span").html(token.name)
}else{
    $("#denglu").show();
    $("#zhuce").show();
    $("#sjyzmdl").show();
    $("#Hoverone").hide();
    $("#tuichu").hide();
}

$("#tuichu").click(function(){
    sessionStorage.removeItem("isLogin");
    $("#denglu").show();
    $("#zhuce").show();
    $("#sjyzmdl").show();
    $("#Hoverone").hide();
    $("#tuichu").hide();
})


var li = document.querySelectorAll(".nav-ul .erji")
var span =document.querySelectorAll(".nav-ul li span")
var ooul =document.querySelector(".nav-ul")
for(var i=0;i<li.length;i++){
    li[i].onmouseover=function(){
        for(var j=0;j<span.length;j++){
            span[j].style.display="none"
        }
        this.firstElementChild.style.display="block"
    }
    ooul.onmouseout=function(){
        for(var j=0;j<span.length;j++){
            span[j].style.display="none"
        }
    }
}

var hoverh =document.querySelectorAll(".brand-hoverh")
for(var i=0;i<hoverh.length;i++){
hoverh[i].previousElementSibling.children[0].onmouseover= function(){
    for(var j=0;j<hoverh.length;j++){
        hoverh[j].style.display="none"
    }
    this.parentNode.nextElementSibling.style.display="block"
    }
    
}
 var contri = document.querySelector(".brand-cont-right")
   for(var i=0;i<contri.length;i++){
       contri[i].onmouseout =function(){
        hoverh[i].style.display="none"
       }
   }

